<template>
  <Computer />
</template>

<script setup>
import { vue} from '@core';
const { computed,onMounted } = vue;
import { ElConfigProvider } from 'element-plus'
import { deleteDiscardedDB } from '@views/fabric/utils/database';
import { useMainStore, useSnapshotStore } from '@views/fabric/store'
import { storeToRefs } from 'pinia';
import { LocalStorageDiscardedKey,databaseId } from "@views/fabric/configs/canvas"


const snapshotStore = useSnapshotStore()
const mainStore = useMainStore()
//组件
import Computer from '@src/views/fabric/Editor/computer.vue';

onMounted(async () => {

  await deleteDiscardedDB();
  await snapshotStore.initSnapshotDatabase();
  mainStore.setSystemFonts();
});

if (process.env.NODE_ENV === 'production') {
  window.onbeforeunload = () => false
}

// 应用注销时向 localStorage 中记录下本次 indexedDB 的数据库ID，用于之后清除数据库
window.addEventListener('unload', () => {
  const discardedDB = localStorage.getItem(LocalStorageDiscardedKey)
  const discardedDBList = discardedDB ? JSON.parse(discardedDB) : []

  discardedDBList.push(databaseId.value)

  const newDiscardedDB = JSON.stringify(discardedDBList)
  localStorage.setItem(LocalStorageDiscardedKey, newDiscardedDB)
});
</script>

<style scoped>


</style>